package com.chengliang.bbs.type;

import com.chengliang.bbs.type.base.BaseEnum;
import lombok.Getter;

/**
 * @author: chengliang
 * @create: 2019-08-25 00:53
 * 经验等级
 */
@Getter
public enum  ExperienceGrade implements BaseEnum {

    /**
     * 经验小于一百
     */
    dacheng(809,"大乘",50000),
    dujie(808,"渡劫",20000),
    dongxu(807,"洞虚",10000),
    huashen(806,"化神",5000),
    yuanying(805,"元婴",2000),
    jindan(804,"金丹",1000),
    zhuji(803,"筑基",500),
    lianqi(802,"练气",200),
    lianti(801,"炼体",100),
    pingmin(800,"平民",0);

    private Integer code;
    private String describe;
    private Integer experience;

    ExperienceGrade(Integer code, String describe,Integer experience) {
        this.code = code;
        this.describe = describe;
        this.experience = experience;
    }

    /**
     * 根据经验值获取等级名称
     * @param experience
     * @return
     */
    public static String getDescriptionByExperience(Integer experience){
        for (ExperienceGrade experienceGrade : ExperienceGrade.values()) {
            if(experienceGrade.experience < experience){
                return experienceGrade.describe;
            }
        }
        return ExperienceGrade.pingmin.describe;
    }

}
